﻿using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Red5.Frame.Utility.DataHandling.Compress.V1
{
    public class Handling : ICompress
    {
        public void CompressData(byte[] data)
        {
            using (MemoryStream output = new MemoryStream())
            {
                using (GZipStream gzip = new GZipStream(output, CompressionMode.Compress))
                {
                    gzip.Write(data, 0, data.Length);
                }
                Data = output.ToArray();
            }
        }
        public void DecompressData(byte[] data)
        {
            using (MemoryStream input = new MemoryStream(data))
            {
                using (GZipStream gzip = new GZipStream(input, CompressionMode.Decompress))
                {
                    using (MemoryStream output = new MemoryStream())
                    {
                        gzip.CopyTo(output);
                        Data = output.ToArray();
                    }
                }
            }
        }
        public byte[] Data { get; set; }
    }
}
